using Castle.MonoRail.Framework;
using DocumentaWeb.Core;
using DocumentaWeb.Core.Messages;

namespace DocumentaWeb.Controllers
{
	[Layout("default")]
	public class ContratistaController:SmartDispatcherController
	{
		private readonly IContratistaService contratistaService;

		public ContratistaController(IContratistaService contratistaService)
		{
			this.contratistaService = contratistaService;
		}

		public void Add()
		{
			RenderView("add");
		}
		[AccessibleThrough(Verb.Post)]
		public void Save([DataBind("contratista")] AddContratistaRequestDto contratista)
		{
			AddContratistaResponseDto response = contratistaService.AddContratista(contratista);

			if (response.ContratistaAdded)
                PropertyBag["responseMessage"] = string.Format("El contratista {0} ha sido guardado Exitosamente",contratista.RazonSocial);

			RenderView("contratistaCreated");
		}
	}
}